package com.shqyang.yexplorer.manager.file;


import com.shqyang.yexplorer.R;
import com.shqyang.yexplorer.util.FileUtils;

import java.io.File;

/**
 * Created by shqyang on 05/30/2021
 */
public class FileManager {

    private static FileManager instance;

    public static FileManager getInstance() {
        if (instance == null) {
            instance = new FileManager();
        }
        return instance;
    }

    public SimpleType getSimpleType(File file) {
        String fileName = file.getName();
        String suffix = FileUtils.getSuffix(fileName);
        SimpleType type;
        switch (suffix) {
            case "mp3":
            case "flac":
                type = SimpleType.MUSIC;
                break;
            default:
                type = SimpleType.UNKNOWN;
        }
        return type;
    }

    public int getFileSimpleTypeImgResId(File file) {
        SimpleType type = getSimpleType(file);
        return getFileSimpleTypeImgResId(type);
    }

    public int getFileSimpleTypeImgResId(SimpleType type) {
        int resId = R.drawable.ic_file_common;
        switch (type) {
            case MUSIC:
                resId = R.drawable.ic_type_music;
                break;
        }
        return resId;
    }

}
